package com.jewel.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.jewel.service.ListService;


@Controller
public class CatalogListController {

    @Autowired
    private ListService listService;

    @RequestMapping(value = "/catalogList", method = RequestMethod.GET)
    public ModelAndView index(@RequestParam Integer listId){
        ModelAndView modelAndView = new ModelAndView();

        modelAndView.addObject("list", this.listService.getListById(listId));
        modelAndView.addObject("articles", this.listService.getAllArticleByListId(listId));

        modelAndView.setViewName("catalogList");
        return  modelAndView;
    }
}
